'use strict';
/**
 * This is a skeleton for creating a store
 */
var AppDispatcher = require('../dispatchers/AppDispatcher');
var EventEmitter = require('events').EventEmitter;
var assign = require('object-assign');


var CHANGE_EVENT = '<%= changeEventName %>';

/**
    FROM FLUX:

    There are a few important things to note in the above code.
    To start, we are maintaining a private data structure called
    `_todos`.
    This object contains all the individual to-do items.
    Because this variable lives outside the class, but within the closure of the module,
    it remains private — it cannot be directly changed from outside of the module.
    This helps us preserve a distinct input/output interface for the flow of data
    by making it impossible to update the store without using an action.

    NOTE: we call this _data to be generic. The idea is the same
 */
var _data = {};

var <%= storeName %> = assign({} , EventEmitter.prototype , {
	/**
   	 * Get the entire collection of TODOs.
   	 * @return {object}
   	 */
  	getAll: function() {
    	return _data;
  	},
	/**
	 * tell the other what happen
	 */
  	emitChange: function() {
    	this.emit(CHANGE_EVENT);
  	},
  	/**
   	 * @param {function} callback
   	 */
  	addChangeListener: function(callback) {
    	this.on(CHANGE_EVENT, callback);
  	},
  	/**
   	 * @param {function} callback
   	 */
  	removeChangeListener: function(callback) {
    	this.removeListener(CHANGE_EVENT, callback);
  	},
	/**
	 * actually doing something
	 */
  	dispatcherIndex: AppDispatcher.register(function(payload) {
    	var action = payload.action;
		/*
		switch (action.actionType) {

		}
		*/
		return true; // No errors. Needed by promise in Dispatcher
	}
});

module.exports = <%= storeName %>
